#!/usr/bin/env python3
# -*- coding:utf-8 -*-

import os

from ctools.converters.convbase import NConverterFilterBase
from ctools.converters.conv_sn import ConvSN2Gv
from ctools.ly_parser.nodes import CTreeNode
from ctools.datahelper.texthelper import TreeTextParser

from ctools.logext import *
import logging

_rlog, _plog, _mlog, _tlog = get_loggers(__file__, __name__, propagate=False)

class ConvCTN2Gv(NConverterFilterBase):
    def process(self, nd:CTreeNode, indent=1, **kwargs) -> str:
        tp = TreeTextParser()
        root = tp.do_parse_text(nd.body, padlen=2)
        sn2gv = ConvSN2Gv(ifilter=self.get_filter())
        return sn2gv.convert(root)

    convert = process
